1 Goal of the script

This script plots all variables to see which ones should be used for further analysis.
Scatterplot of each variable will be plotted.

dir_in <- "analysis_all.cycles/derived_data/"
dir_out <- "analysis_all.cycles/plots"

Raw data must be located in ~/analysis_all.cycles/derived_data/.
Formatted data will be saved in ~/analysis_all.cycles/plots.

1.1 The knit directory for this script is the project directory.

2 Load packages

pack_to_load <- c("R.utils", "tools", "ggplot2", "doBy", "tidyverse", "patchwork", "ggsci")
sapply(pack_to_load, library, character.only = TRUE, logical.return = TRUE)
Warning: package 'R.utils' was built under R version 4.1.3
Warning: package 'doBy' was built under R version 4.1.3
Warning: package 'tibble' was built under R version 4.1.3
Warning: package 'tidyr' was built under R version 4.1.3
Warning: package 'readr' was built under R version 4.1.3
Warning: package 'dplyr' was built under R version 4.1.3
  R.utils     tools   ggplot2      doBy tidyverse patchwork     ggsci 
     TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE 

3 Get name, path and information of the file

data_file <- list.files(dir_in, pattern = "\\.Rbin$", full.names = TRUE)
md5_in <- md5sum(data_file)
info_in <- data.frame(file = basename(names(md5_in)), checksum = md5_in, row.names = NULL)

4 Load data into R object

imp_data <- loadObject(data_file)
str(imp_data)
'data.frame':   120 obs. of  43 variables:
 $ Sample                  : chr  "FLT4-12" "FLT4-12" "FLT4-12" "FLT4-12" ...
 $ Cycle                   : Factor w/ 5 levels "0","50","250",..: 1 1 1 4 4 4 5 5 5 3 ...
 $ Spot                    : chr  "A" "B" "C" "A" ...
 $ Raw.material            : Factor w/ 2 levels "flint","lydite": 1 1 1 1 1 1 1 1 1 1 ...
 $ Contact.material        : chr  "skin pad" "skin pad" "skin pad" "skin pad" ...
 $ Acquisition.date.time   : chr  "8/10/2021 7:41:36 AM" "8/10/2021 7:59:13 AM" "8/10/2021 8:14:18 AM" "10/12/2021 8:36:04 AM" ...
 $ Analysis.date           : chr  "2022/10/04" "2022/10/04" "2022/10/04" "2022/10/04" ...
 $ Analysis.time           : 'times' num  0.664 0.665 0.665 0.665 0.665 ...
  ..- attr(*, "format")= chr "h:m:s"
 $ Sq                      : num  863 1315 809 1812 941 ...
 $ Ssk                     : num  2.051 2.239 1.861 2.288 0.571 ...
 $ Sku                     : num  9.09 11.98 10.14 9.83 3.4 ...
 $ Sp                      : num  4894 7904 4254 10948 3385 ...
 $ Sv                      : num  1498 3242 2077 2361 2514 ...
 $ Sz                      : num  6392 11146 6331 13309 5899 ...
 $ Sa                      : num  605 813 515 1215 714 ...
 $ Smr                     : num  0.668 0.4112 1.4301 0.0768 1.2472 ...
 $ Smc                     : num  997 1053 610 2112 1377 ...
 $ Sxp                     : num  838 1869 1297 1533 1463 ...
 $ Sal                     : num  13.1 11 17.5 12.8 15 ...
 $ Str                     : num  0.212 NA 0.749 0.151 0.758 ...
 $ Std                     : num  3.49 130.02 115.75 130 98.74 ...
 $ Sdq                     : num  0.232 0.286 0.153 0.511 0.319 ...
 $ Sdr                     : num  2.33 3.36 1.11 9.22 4.5 ...
 $ Vm                      : num  0.0991 0.1868 0.1072 0.2229 0.0532 ...
 $ Vv                      : num  1.096 1.24 0.717 2.335 1.43 ...
 $ Vmp                     : num  0.0991 0.1868 0.1072 0.2229 0.0532 ...
 $ Vmc                     : num  0.559 0.714 0.508 1.136 0.768 ...
 $ Vvc                     : num  1.055 1.127 0.641 2.264 1.333 ...
 $ Vvv                     : num  0.0415 0.1124 0.076 0.0704 0.0969 ...
 $ Maximum.depth.of.furrows: num  2834 3768 2058 6620 3031 ...
 $ Mean.depth.of.furrows   : num  1250 1154 683 2720 1205 ...
 $ Mean.density.of.furrows : num  2801 3123 3305 3697 4268 ...
 $ Isotropy                : num  21.2 NA 74.9 15.1 75.8 ...
 $ First.direction         : num  1.71e-03 1.27e+02 1.29e+02 1.37e+02 1.31e-02 ...
 $ Second.direction        : num  137 117 112 118 147 ...
 $ Third.direction         : num  154.8 90 105 154.8 98.7 ...
 $ Texture.isotropy        : num  47 13.8 80.3 10.5 85.8 ...
 $ epLsar                  : num  0.005379 0.004747 0.000594 0.006092 0.002104 ...
 $ NewEplsar               : num  0.0178 0.0163 0.0176 0.0177 0.0172 ...
 $ Asfc                    : num  3.94 5.89 1.79 14.2 7.9 ...
 $ Smfc                    : num  14.89 58.74 4.31 3.7 1.75 ...
 $ HAsfc9                  : num  0.649 8.295 0.6 0.703 0.302 ...
 $ HAsfc81                 : num  1.885 12.216 1.174 1.652 0.594 ...
 - attr(*, "comment")= Named chr [1:42] "µm" "points" "µm" "µm" ...
  ..- attr(*, "names")= chr [1:42] "Axis length - X" "Axis size - X" "Axis spacing - X" "Axis length - Y" ...
# add another column which concatenates Sample and Spot 
imp_data$ID <- paste(imp_data$Sample, imp_data$Spot)
imp_data <- imp_data[c(1:3, 44, 4:43)]

# copy the column Cycle and convert into numeric
imp_data$Stroke <- paste(imp_data$Cycle) 
imp_data[["Stroke"]] <- as.numeric(imp_data[["Stroke"]],levels=c("0", "50", "250", "1000",
                        "2000"))

The imported file is: “~/analysis_all.cycles/derived_data/AvsN_all.cycles.Rbin”


5 Prepare variables

5.1 Define numeric variables

num.var <- 10:44

The following variables will be used:

[10] Sq
[11] Ssk
[12] Sku
[13] Sp
[14] Sv
[15] Sz
[16] Sa
[17] Smr
[18] Smc
[19] Sxp
[20] Sal
[21] Str
[22] Std
[23] Sdq
[24] Sdr
[25] Vm
[26] Vv
[27] Vmp
[28] Vmc
[29] Vvc
[30] Vvv
[31] Maximum.depth.of.furrows
[32] Mean.depth.of.furrows
[33] Mean.density.of.furrows
[34] Isotropy
[35] First.direction
[36] Second.direction
[37] Third.direction
[38] Texture.isotropy
[39] epLsar
[40] NewEplsar
[41] Asfc
[42] Smfc
[43] HAsfc9
[44] HAsfc81

6 Plot each of the selected numeric variable

6.1 Sorted by contact material

6.1.1 artificial vs. natural bone: flint samples

flint <- filter(imp_data, Raw.material == "flint")


for (i in num.var){
 
 # get the min/max range of the data set
 range_var <- range(flint[i]) 
  
    # plot bone plate
    f_bp <- ggplot(flint[grep("bone plate", flint[["Contact.material"]]), ], 
            aes_string(y = names(imp_data)[i], x = "Cycle")) +
            geom_point(aes(shape = Spot, colour = Sample), size = 3) + 
            labs(title = "flint - bone plate", y = names(imp_data)[i], x = "cycle") + 
            coord_cartesian(ylim = range_var) +
            guides(colour = "none") +
            geom_line(aes(group = Spot,), colour = "#FAD510") +  
            scale_colour_manual(values = "#FAD510") +
            theme_classic() 

    # plot cow scapula 
    f_cs <- ggplot(flint[grep("cow scapula", flint[["Contact.material"]]), ], 
            aes_string(y = names(imp_data)[i], x = "Cycle")) +
            geom_point(aes(shape = Spot, colour = Sample), size = 3) +
            labs(title = "flint - cow scapula", y = names(imp_data)[i], x = "cycle") + 
            coord_cartesian(ylim = range_var) +
            guides(colour = "none") +
            scale_colour_manual(values = "#CB2314") +
            geom_line(aes(group = Spot,), colour = "#CB2314") +
            theme_classic() 

      # combine the flint plots 
    f.bone <- f_bp + f_cs + plot_layout(width = c(3/6, 3/6), guides = 'collect')  
       
    print(f.bone)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_f.bone_", names(imp_data)[i],
                ".pdf")
    ggsave(filename = file_out, plot = f.bone, path = dir_out, device = "pdf")

}

Warning: Removed 4 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 row(s) containing missing values (geom_path).
Warning: Removed 4 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 row(s) containing missing values (geom_path).

Warning: Removed 4 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 row(s) containing missing values (geom_path).
Warning: Removed 4 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 row(s) containing missing values (geom_path).

Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 rows containing missing values (geom_point).

6.1.2 artificial vs. natural bone: lydite samples

lydite <- filter(imp_data, Raw.material == "lydite")

for (i in num.var){
    
  # get the min/max range of the data set
  range_var <- range(lydite[i]) 
  
    # plot bone plate 
    l_bp <- ggplot(lydite[grep("bone plate", lydite[["Contact.material"]]), ], 
            aes_string(y = names(imp_data)[i], x = "Cycle")) +
            geom_point(aes(shape = Spot, colour = Sample), size = 3) +
            labs(title = "lydite - bone plate", y = names(imp_data)[i], x = "cycle") + 
            coord_cartesian(ylim = range_var) +
            guides(colour = "none") +
            geom_line(aes(group = Spot,), colour = "#FAD510") +  
            scale_colour_manual(values = "#FAD510") +
            theme_classic() 
    
    # plot cow scapula 
    l_cs <- ggplot(lydite[grep("cow scapula", lydite[["Contact.material"]]), ], 
            aes_string(y = names(imp_data)[i], x = "Cycle")) +
            geom_point(aes(shape = Spot, colour = Sample), size = 3) +
            labs(title = "lydite - cow scapula", y = names(imp_data)[i], x = "cycle") + 
            coord_cartesian(ylim = range_var) +
            guides(colour = "none") +
            scale_colour_manual(values = "#CB2314") +
            geom_line(aes(group = Spot,), colour = "#CB2314") +
            theme_classic() 

      # combine the lydite plots 
    l.bone <- l_bp + l_cs + plot_layout(width = c(3/6, 3/6), guides = 'collect')  
   
     print(l.bone)
 
  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_l.bone_", 
                names(imp_data)[i], ".pdf")
    ggsave(filename = file_out, plot = l.bone, path = dir_out, device = "pdf")
    

}

Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 row(s) containing missing values (geom_path).
Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 row(s) containing missing values (geom_path).

Warning: Removed 1 rows containing missing values (geom_point).
Removed 1 row(s) containing missing values (geom_path).
Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 row(s) containing missing values (geom_path).

Warning: Removed 1 rows containing missing values (geom_point).
Removed 1 row(s) containing missing values (geom_path).
Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 row(s) containing missing values (geom_path).

Warning: Removed 1 rows containing missing values (geom_point).
Warning: Removed 1 rows containing missing values (geom_point).

6.1.3 artificial vs. natural skin: flint samples

for (i in num.var){   
    
  # get the min/max range of the data set
  range_var <- range(flint[i]) 
  
    # plot skin pad 
    f_sp <- ggplot(flint[grep("skin pad", flint[["Contact.material"]]), ], 
            aes_string(y = names(imp_data)[i], x = "Cycle")) +
            geom_point(aes(shape = Spot, colour = Sample), size = 3) +
            labs(title = "flint - skin pad", y = names(imp_data)[i], x = "cycle") + 
            coord_cartesian(ylim = range_var) +
            guides(colour = "none") +
            geom_line(aes(group = Spot,), colour = "#046C9A") + 
            scale_colour_manual(values = "#046C9A") +
            theme_classic()  

    # plot pig skin 
    f_ps <- ggplot(flint[grep("pig skin", flint[["Contact.material"]]), ], 
            aes_string(y = names(imp_data)[i], x = "Cycle")) +
            geom_point(aes(shape = Spot, colour = Sample), size = 3) +
            labs(title = "flint - pig skin", y = names(imp_data)[i], x = "cycle") + 
            coord_cartesian(ylim = range_var) +
            guides(colour = "none") +
            scale_colour_manual(values = "#52854c") +
            geom_line(aes(group = Spot,), colour = "#52854c") +
            theme_classic() 

      # combine the flint and the lydite plots 
    f.skin <- f_sp + f_ps + plot_layout(width = c(3/6, 3/6), guides = 'collect')  
       
    print(f.skin)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_f.skin_", 
                names(imp_data)[i], ".pdf")
    ggsave(filename = file_out, plot = f.skin, path = dir_out, device = "pdf")

}

Warning: Removed 2 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 4 rows containing missing values (geom_point).
Warning: Removed 3 row(s) containing missing values (geom_path).
Warning: Removed 2 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 4 rows containing missing values (geom_point).
Warning: Removed 3 row(s) containing missing values (geom_path).

Warning: Removed 2 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 4 rows containing missing values (geom_point).
Warning: Removed 3 row(s) containing missing values (geom_path).
Warning: Removed 2 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 4 rows containing missing values (geom_point).
Warning: Removed 3 row(s) containing missing values (geom_path).

Warning: Removed 3 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).
Warning: Removed 3 rows containing missing values (geom_point).
Warning: Removed 2 row(s) containing missing values (geom_path).

6.1.4 artificial vs. natural skin: lydite samples

for (i in num.var){
    
  # get the min/max range of the data set
  range_var <- range(lydite[i]) 
  
    # plot skin pad 
    l_sp <- ggplot(lydite[grep("skin pad", lydite[["Contact.material"]]), ], 
            aes_string(y = names(imp_data)[i], x = "Cycle")) +
            geom_point(aes(shape = Spot, colour = Sample), size = 3) + 
            labs(title = "lydite - skin pad", y = names(imp_data)[i], x = "cycle") + 
            coord_cartesian(ylim = range_var) +
            guides(colour = "none") +
            geom_line(aes(group = Spot,), colour = "#046C9A") + 
            scale_colour_manual(values = "#046C9A") +
            theme_classic()

    # plot pig skin 
    l_ps <- ggplot(lydite[grep("pig skin", lydite[["Contact.material"]]), ], 
            aes_string(y = names(imp_data)[i], x = "Cycle")) +
            geom_point(aes(shape = Spot, colour = Sample), size = 3) +
            labs(title = "lydite - pig skin", y = names(imp_data)[i], x = "cycle") + 
            coord_cartesian(ylim = range_var) +
            guides(colour = "none") +
            scale_colour_manual(values = "#52854c") +
            geom_line(aes(group = Spot,), colour = "#52854c") +
            theme_classic()

      # combine the flint and the lydite plots 
    l.skin <- l_sp + l_ps + plot_layout(width = c(3/6, 3/6), guides = 'collect')  
    print(l.skin)


  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_l.skin_", names(imp_data)[i],
                ".pdf")
    ggsave(filename = file_out, plot = l.skin, path = dir_out, device = "pdf")


}

7 Plot the mean value (3 measurements) of each of the selected numeric variable

7.1 Sorted by contact material

7.1.1 cow scapula & bone plate: Sq

# remove possible outliers (based on values and prior plots)
imp_data2 <- imp_data[-c(1, 4, 7, 10, 13, 18, 32, 47, 75), ]

# add a column that combines sample and cycle
ID.cycle <- unite(imp_data2, ID_Cycle, c(Sample, Cycle), remove = FALSE)

# compute the mean of the three spots per sample 
mean_cycle <- summaryBy(.~ ID_Cycle + Sample + Stroke + Raw.material + Contact.material, 
                         data = ID.cycle, FUN = mean)

# define new num.var for mean_cycle 
num.var2 <- 6:length(mean_cycle)
for (j in num.var2) cat("[",j,"] ", names(mean_cycle)[j], "\n", sep="")
[6] Analysis.time.mean
[7] Sq.mean
[8] Ssk.mean
[9] Sku.mean
[10] Sp.mean
[11] Sv.mean
[12] Sz.mean
[13] Sa.mean
[14] Smr.mean
[15] Smc.mean
[16] Sxp.mean
[17] Sal.mean
[18] Str.mean
[19] Std.mean
[20] Sdq.mean
[21] Sdr.mean
[22] Vm.mean
[23] Vv.mean
[24] Vmp.mean
[25] Vmc.mean
[26] Vvc.mean
[27] Vvv.mean
[28] Maximum.depth.of.furrows.mean
[29] Mean.depth.of.furrows.mean
[30] Mean.density.of.furrows.mean
[31] Isotropy.mean
[32] First.direction.mean
[33] Second.direction.mean
[34] Third.direction.mean
[35] Texture.isotropy.mean
[36] epLsar.mean
[37] NewEplsar.mean
[38] Asfc.mean
[39] Smfc.mean
[40] HAsfc9.mean
[41] HAsfc81.mean
     # plot bone plate 
     Sq.bp <- ggplot(mean_cycle[grep("bone plate", mean_cycle[["Contact.material"]]), ], 
              aes_string(y = "Sq.mean", x = "Stroke")) +
              geom_point(aes(colour = Sample), size = 3) +
              geom_line(aes(group = Sample)) +  
              scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
              labs(title = "bone plate", y = NULL, x = "cycle") + 
              coord_cartesian(ylim = c(0, 7000)) + 
              scale_colour_manual(values = c("#FAD50F", "#FAD50F")) +
              theme_classic() 
    
    # plot cow scapula 
    Sq.cs <- ggplot(mean_cycle[grep("cow scapula", mean_cycle[["Contact.material"]]), ],
             aes_string(y = "Sq.mean", x = "Stroke")) +
             geom_point(aes(colour = Sample), size = 3) +
             geom_line(aes(group = Sample)) +
             scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) + 
             coord_cartesian(ylim = c(0, 7000)) +
             labs(title = "cow scapula", y = "ΔSq [nm]", x = "cycle") + 
             scale_colour_manual(values = c("#CB2213", "#CB2213")) +
             theme_classic() 


     # combine the plots 
   Sq.bone.mean <- Sq.cs + Sq.bp + plot_layout(width = c(3/6, 3/6), guides = 'collect')  
       
   print(Sq.bone.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_Sq.bone.mean", ".pdf")
    ggsave(filename = file_out, plot = Sq.bone.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.2 pig skin & skin pad: Sq

  Sq.sp <- ggplot(mean_cycle[grep("skin pad", mean_cycle[["Contact.material"]]), ],
           aes_string(y = "Sq.mean", x = "Stroke")) +
           geom_point(aes(colour = Sample), size = 3) +
           geom_line(aes(group = Sample)) +
           scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
           labs(title = "skin pad", y = NULL, x = "cycle") + 
           coord_cartesian(ylim = c(0, 6000)) +  
           scale_colour_manual(values = c("#52854B", "#52854B")) +
           theme_classic() 

    Sq.ps <- ggplot(mean_cycle[grep("pig skin", mean_cycle[["Contact.material"]]), ],
             aes_string(y = "Sq.mean", x = "Stroke")) +
             geom_point(aes(colour = Sample), size = 3) +
             geom_line(aes(group = Sample)) +
             scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
             coord_cartesian(ylim = c(0, 6000)) +
             labs(title = "pig skin", y = "ΔSq [nm]", x = "cycle") + 
             scale_colour_manual(values = c("#036C9A", "#036C9A")) +
             theme_classic() 

      # combine the plots 
    Sq.skin.mean <- Sq.ps + Sq.sp + plot_layout(width = c(3/6, 3/6), guides = 'collect')  
       
    print(Sq.skin.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_Sq.skin.mean", ".pdf")
    ggsave(filename = file_out, plot = Sq.skin.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.3 cow scapula & bone plate: Vmc

     Vmc.bp <- ggplot(mean_cycle[grep("bone plate", mean_cycle[["Contact.material"]]), ],
               aes_string(y = "Vmc.mean", x = "Stroke")) +
               geom_point(aes(colour = Sample), size = 3) +
               geom_line(aes(group = Sample)) +
               scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +                 
               labs(title = "bone plate", y = NULL, x = "cycle") + 
               coord_cartesian(ylim = c(0, 3.5)) + 
               scale_colour_manual(values = c("#FAD50F", "#FAD50F")) +
               theme_classic() 

     Vmc.cs <- ggplot(mean_cycle[grep("cow scapula", mean_cycle[["Contact.material"]]), ],
              aes_string(y = "Vmc.mean", x = "Stroke")) +
              geom_point(aes(colour = Sample), size = 3) +
              geom_line(aes(group = Sample)) +
              scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) + 
              coord_cartesian(ylim = c(0, 3.5)) +
              labs(title = "cow scapula", y = "Vmc [µm³/µm²]", x = "cycle") + 
              scale_colour_manual(values = c("#CB2213", "#CB2213")) +
              theme_classic() 

     # combine the plots 
     Vmc.bone.mean <- Vmc.cs + Vmc.bp + plot_layout(width = c(3/6, 3/6), guides = 'collect')  
     print(Vmc.bone.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_Vmc.bone.mean", ".pdf")
    ggsave(filename = file_out, plot = Vmc.bone.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.4 pig skin & skin pad: Vmc

  Vmc.sp <- ggplot(mean_cycle[grep("skin pad", mean_cycle[["Contact.material"]]), ],
            aes_string(y = "Vmc.mean", x = "Stroke")) +
            geom_point(aes(colour = Sample), size = 3) +
            geom_line(aes(group = Sample)) +
            scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
            labs(title = "skin pad", y = NULL, x = "cycle") + 
            coord_cartesian(ylim = c(0, 3.5)) +  
            scale_colour_manual(values = c("#52854B", "#52854B")) + 
            theme_classic() 

    Vmc.ps <- ggplot(mean_cycle[grep("pig skin", mean_cycle[["Contact.material"]]), ],
              aes_string(y = "Vmc.mean", x = "Stroke")) +
              geom_point(aes(colour = Sample), size = 3) +
              geom_line(aes(group = Sample)) +
              scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
              coord_cartesian(ylim = c(0, 3.5)) +
              labs(title = "pig skin", y = "Vmc [µm³/µm²]", x = "cycle") + 
              scale_colour_manual(values = c("#036C9A", "#036C9A")) +
              theme_classic() 

    # combine the plots 
    Vmc.skin.mean <- Vmc.ps + Vmc.sp + plot_layout(width = c(3/6, 3/6), guides = 'collect')  
    print(Vmc.skin.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_Vmc.skin.mean", ".pdf")
    ggsave(filename = file_out, plot = Vmc.skin.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.5 cow scapula & bone plate: HAsfc9

     HAsfc9.bp <- ggplot(mean_cycle[grep("bone plate", mean_cycle[["Contact.material"]]), ],
                  aes_string(y = "HAsfc9.mean", x = "Stroke")) +
                  geom_point(aes(colour = Sample), size = 3) +
                  geom_line(aes(group = Sample)) +
                  scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
                  labs(title = "bone plate", y = NULL, x = "cycle") + 
                  coord_cartesian(ylim = c(0.0, 11.0)) +
                  scale_colour_manual(values = c("#FAD50F", "#FAD50F")) +
                 theme_classic() 

    HAsfc9.cs <- ggplot(mean_cycle[grep("cow scapula", mean_cycle[["Contact.material"]]), ],
                 aes_string(y = "HAsfc9.mean", x = "Stroke")) +
                 geom_point(aes(colour = Sample), size = 3) +
                 geom_line(aes(group = Sample)) +
                 scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
                 coord_cartesian(ylim = c(0.0, 11.0)) +
                 labs(title = "cow scapula", y = "HAsfc9", x = "cycle") + 
                 scale_colour_manual(values = c("#CB2213", "#CB2213")) +
                 theme_classic() 

      # combine the plots 
    HAsfc9.bone.mean <- HAsfc9.cs + HAsfc9.bp + plot_layout(width = c(3/6, 3/6), 
                        guides = 'collect')  
       
    print(HAsfc9.bone.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_HAsfc9.bone.mean", ".pdf")
    ggsave(filename = file_out, plot = HAsfc9.bone.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.6 pig skin & skin pad: HAsfc9

  HAsfc9.sp <- ggplot(mean_cycle[grep("skin pad", mean_cycle[["Contact.material"]]), ],
               aes_string(y = "HAsfc9.mean", x = "Stroke")) +
               geom_point(aes(colour = Sample), size = 3) +
               geom_line(aes(group = Sample)) +
               scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) + 
               labs(title = "skin pad", y = NULL, x = "cycle") + 
               coord_cartesian(ylim = c(0.0, 11.0)) +  
               scale_colour_manual(values = c("#52854B", "#52854B")) +
               theme_classic() 

    HAsfc9.ps <- ggplot(mean_cycle[grep("pig skin", mean_cycle[["Contact.material"]]), ],
                 aes_string(y = "HAsfc9.mean", x = "Stroke")) +
                 geom_point(aes(colour = Sample), size = 3) +
                 geom_line(aes(group = Sample)) +
                 scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
                 coord_cartesian(ylim = c(0.0, 11.0)) +
                 labs(title = "pig skin", y = "HAsfc9", x = "cycle") + 
                 scale_colour_manual(values = c("#036C9A", "#036C9A")) +
                theme_classic() 

    # combine the plots 
    HAsfc9.skin.mean <- HAsfc9.ps + HAsfc9.sp + plot_layout(width = c(3/6, 3/6), guides =
                      'collect')  
       
    print(HAsfc9.skin.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_HAsfc9.skin.mean", ".pdf")
    ggsave(filename = file_out, plot = HAsfc9.skin.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.7 cow scapula & bone plate: epLsar

     epLsar.bp <- ggplot(mean_cycle[grep("bone plate", mean_cycle[["Contact.material"]]), ],
                  aes_string(y = "epLsar.mean", x = "Stroke")) +
                  geom_point(aes(colour = Sample), size = 3) +
                  geom_line(aes(group = Sample)) +
                  scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
                  labs(title = "bone plate", y = NULL, x = "cycle") + 
                  coord_cartesian(ylim = c(0.000, 0.005)) +
                  scale_colour_manual(values = c("#FAD50F", "#FAD50F")) +
                 theme_classic() 

    epLsar.cs <- ggplot(mean_cycle[grep("cow scapula", mean_cycle[["Contact.material"]]), ],
                 aes_string(y = "epLsar.mean", x = "Stroke")) +
                 geom_point(aes(colour = Sample), size = 3) +
                 geom_line(aes(group = Sample)) +
                 scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
                 coord_cartesian(ylim = c(0.000, 0.005)) +
                 labs(title = "cow scapula", y = "epLsar", x = "cycle") + 
                 scale_colour_manual(values = c("#CB2213", "#CB2213")) +
                 theme_classic() 

      # combine the plots 
    epLsar.bone.mean <- epLsar.cs + epLsar.bp + plot_layout(width = c(3/6, 3/6), 
                        guides = 'collect')  
       
    print(epLsar.bone.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_epLsar.bone.mean", ".pdf")
    ggsave(filename = file_out, plot = epLsar.bone.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.8 pig skin & skin pad: epLsar

  epLsar.sp <- ggplot(mean_cycle[grep("skin pad", mean_cycle[["Contact.material"]]), ],
               aes_string(y = "epLsar.mean", x = "Stroke")) +
               geom_point(aes(colour = Sample), size = 3) +
               geom_line(aes(group = Sample)) +
               scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) + 
               labs(title = "skin pad", y = NULL, x = "cycle") + 
               coord_cartesian(ylim = c(0.000, 0.005)) +  
               scale_colour_manual(values = c("#52854B", "#52854B")) +
               theme_classic() 

    epLsar.ps <- ggplot(mean_cycle[grep("pig skin", mean_cycle[["Contact.material"]]), ],
                 aes_string(y = "epLsar.mean", x = "Stroke")) +
                 geom_point(aes(colour = Sample), size = 3) +
                 geom_line(aes(group = Sample)) +
                 scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
                 coord_cartesian(ylim = c(0.000, 0.005)) +
                 labs(title = "pig skin", y = "epLsar", x = "cycle") + 
                 scale_colour_manual(values = c("#036C9A", "#036C9A")) +
                 theme_classic() 

      # combine the plots 
    epLsar.skin.mean <- epLsar.ps + epLsar.sp + plot_layout(width = c(3/6, 3/6), 
                        guides = 'collect')  
       
  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_epLsar.skin.mean", ".pdf")
    ggsave(filename = file_out, plot = epLsar.skin.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.9 cow scapula & bone plate: Asfc

     Asfc.bp <- ggplot(mean_cycle[grep("bone plate", mean_cycle[["Contact.material"]]), ],
                aes_string(y = "Asfc.mean", x = "Stroke")) +
                geom_point(aes(colour = Sample), size = 3) +
                geom_line(aes(group = Sample)) +
                scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
                labs(title = "bone plate", y = NULL, x = "cycle") + 
                coord_cartesian(ylim = c(0, 35)) +
                scale_colour_manual(values = c("#FAD50F", "#FAD50F")) +
                theme_classic() 

    Asfc.cs <- ggplot(mean_cycle[grep("cow scapula", mean_cycle[["Contact.material"]]), ],
               aes_string(y = "Asfc.mean", x = "Stroke")) +
               geom_point(aes(colour = Sample), size = 3) +
               geom_line(aes(group = Sample)) +
               scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) + 
               coord_cartesian(ylim = c(0, 35)) +
               labs(title = "cow scapula", y = "Asfc", x = "cycle") + 
               scale_colour_manual(values = c("#CB2213", "#CB2213")) +
               theme_classic() 

    # combine the plots 
    Asfc.bone.mean <- Asfc.cs + Asfc.bp + plot_layout(width = c(3/6, 3/6), 
                      guides = 'collect')  
       
    print(Asfc.bone.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_Asfc.bone.mean", ".pdf")
    ggsave(filename = file_out, plot = Asfc.bone.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

7.1.10 cow scapula & bone plate: Asfc

  Asfc.sp <- ggplot(mean_cycle[grep("skin pad", mean_cycle[["Contact.material"]]), ],
             aes_string(y = "Asfc.mean", x = "Stroke")) +
             geom_point(aes(colour = Sample), size = 3) +
             geom_line(aes(group = Sample)) +
             scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) +
             labs(title = "skin pad", y = NULL, x = "cycle") + 
             coord_cartesian(ylim = c(0, 35)) + 
             scale_colour_manual(values = c("#52854B", "#52854B")) +
             theme_classic() 

    Asfc.ps <- ggplot(mean_cycle[grep("pig skin", mean_cycle[["Contact.material"]]), ],
               aes_string(y = "Asfc.mean", x = "Stroke")) +
               geom_point(aes(colour = Sample), size = 3) +
               geom_line(aes(group = Sample)) +
               scale_x_continuous(breaks = c(0, 50, 250, 1000, 2000)) + 
               coord_cartesian(ylim = c(0, 35)) +
               labs(title = "pig skin", y = "Asfc", x = "cycle") + 
               scale_colour_manual(values = c("#036C9A", "#036C9A")) +
               theme_classic() 

      # combine the plots 
    Asfc.skin.mean <- Asfc.ps + Asfc.sp + plot_layout(width = c(3/6, 3/6), 
                      guides = 'collect')  
       
    print(Asfc.skin.mean)

  # save to PDF
    file_out <- paste0(file_path_sans_ext(info_in[["file"]]), "_Asfc.skin.mean", ".pdf")
    ggsave(filename = file_out, plot = Asfc.skin.mean, path = dir_out, device = "pdf", 
           width = 350, height = 270, units = "mm")

8 sessionInfo() and RStudio version

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
[1] tools     stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] ggsci_2.9         patchwork_1.1.1   forcats_0.5.1     stringr_1.4.0    
 [5] dplyr_1.0.9       purrr_0.3.4       readr_2.1.2       tidyr_1.2.0      
 [9] tibble_3.1.6      tidyverse_1.3.1   doBy_4.6.13       ggplot2_3.3.6    
[13] R.utils_2.11.0    R.oo_1.24.0       R.methodsS3_1.8.1

loaded via a namespace (and not attached):
 [1] lubridate_1.8.0      lattice_0.20-44      assertthat_0.2.1    
 [4] digest_0.6.29        utf8_1.2.2           R6_2.5.1            
 [7] cellranger_1.1.0     backports_1.4.1      reprex_2.0.1        
[10] evaluate_0.15        highr_0.9            httr_1.4.2          
[13] pillar_1.7.0         rlang_1.0.2          readxl_1.4.0        
[16] rstudioapi_0.13      jquerylib_0.1.4      Matrix_1.3-3        
[19] rmarkdown_2.14       labeling_0.4.2       munsell_0.5.0       
[22] broom_0.8.0          compiler_4.1.0       Deriv_4.1.3         
[25] modelr_0.1.8         xfun_0.30            pkgconfig_2.0.3     
[28] microbenchmark_1.4.9 htmltools_0.5.2      tidyselect_1.1.2    
[31] fansi_1.0.3          crayon_1.5.1         tzdb_0.3.0          
[34] dbplyr_2.1.1         withr_2.5.0          MASS_7.3-54         
[37] grid_4.1.0           jsonlite_1.8.0       gtable_0.3.0        
[40] lifecycle_1.0.1      DBI_1.1.2            magrittr_2.0.3      
[43] scales_1.2.0         cli_3.3.0            stringi_1.7.6       
[46] farver_2.1.0         fs_1.5.2             xml2_1.3.3          
[49] bslib_0.3.1          ellipsis_0.3.2       generics_0.1.2      
[52] vctrs_0.4.1          glue_1.6.2           hms_1.1.1           
[55] fastmap_1.1.0        yaml_2.3.5           colorspace_2.0-3    
[58] rvest_1.0.2          knitr_1.39           haven_2.5.0         
[61] sass_0.4.1          

RStudio version 1.4.1717.


9 Cite R packages used

for (i in pack_to_load) print(citation(i), bibtex = FALSE)

To cite package 'R.utils' in publications use:

  Henrik Bengtsson (2021). R.utils: Various Programming Utilities. R
  package version 2.11.0. https://CRAN.R-project.org/package=R.utils


The 'tools' package is part of R.  To cite R in publications use:

  R Core Team (2021). R: A language and environment for statistical
  computing. R Foundation for Statistical Computing, Vienna, Austria.
  URL https://www.R-project.org/.

We have invested a lot of time and effort in creating R, please cite it
when using it for data analysis. See also 'citation("pkgname")' for
citing R packages.


To cite ggplot2 in publications, please use:

  H. Wickham. ggplot2: Elegant Graphics for Data Analysis.
  Springer-Verlag New York, 2016.


To cite package 'doBy' in publications use:

  Søren Højsgaard and Ulrich Halekoh (2022). doBy: Groupwise
  Statistics, LSmeans, Linear Estimates, Utilities. R package version
  4.6.13. https://CRAN.R-project.org/package=doBy

ATTENTION: This citation information has been auto-generated from the
package DESCRIPTION file and may need manual editing, see
'help("citation")'.


  Wickham et al., (2019). Welcome to the tidyverse. Journal of Open
  Source Software, 4(43), 1686, https://doi.org/10.21105/joss.01686


To cite package 'patchwork' in publications use:

  Thomas Lin Pedersen (2020). patchwork: The Composer of Plots. R
  package version 1.1.1. https://CRAN.R-project.org/package=patchwork


To cite package 'ggsci' in publications use:

  Nan Xiao (2018). ggsci: Scientific Journal and Sci-Fi Themed Color
  Palettes for 'ggplot2'. R package version 2.9.
  https://CRAN.R-project.org/package=ggsci

END OF SCRIPT